Skip to content

doc,test: mem protection must be observed in ffi#62818

Open
bengl wants to merge 3 commits intonodejs:mainfrom
bengl:bengl/ffi-mem-prot-doc-test
Open

doc,test: mem protection must be observed in ffi#62818
bengl wants to merge 3 commits intonodejs:mainfrom
bengl:bengl/ffi-mem-prot-doc-test

Conversation

@bengl
Copy link
Copy Markdown
Member

@bengl bengl commented Apr 19, 2026

When using ffi.toBuffer, memory protection on any memory pages exposed must be observed by the caller, otherwise crashes will occur.

Now documented, and tested.

@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Apr 19, 2026
@bengl bengl requested a review from ShogunPanda April 19, 2026 14:05
@bengl bengl marked this pull request as ready for review April 19, 2026 14:06
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 19, 2026

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 89.62%. Comparing base (3f52482) to head (8e3890d).
⚠️ Report is 64 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #62818      +/-   ##
==========================================
- Coverage   91.55%   89.62%   -1.93%     
==========================================
  Files         356      706     +350     
  Lines      149601   219136   +69535     
  Branches    23395    41982   +18587     
==========================================
+ Hits       136967   196410   +59443     
- Misses      12371    14618    +2247     
- Partials      263     8108    +7845     

see 484 files with indirect coverage changes

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • πŸ“¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ShogunPanda
Copy link
Copy Markdown
Contributor

ShogunPanda commented Apr 19, 2026

Codewise it LGTM!
Can you expand the documentation just a little bit?
Once CI succeeds I'll be more than happy to approve it!

Comment thread test/ffi/test-ffi-readonly-write.js Outdated
'-p',
`
const ffi = require('node:ffi');
const { functions } = ffi.dlopen('${libraryPath}', ${symbols})
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const { functions } = ffi.dlopen('${libraryPath}', ${symbols})
const { functions } = ffi.dlopen(${JSON.stringify(libraryPath)}, ${symbols})

#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The #ifdef _WIN32 below this line makes me assume that this file is also compiled on Windows, which means that this include here (and the actual function that was added) should probably be in #ifndef _WIN32 guards?

When using ffi.toBuffer, memory protection on any memory pages exposed
must be observed by the caller, otherwise crashes will occur.

Now documented, and tested.
@bengl bengl force-pushed the bengl/ffi-mem-prot-doc-test branch from 43f68d7 to b448d7f Compare April 20, 2026 02:07
@bengl bengl force-pushed the bengl/ffi-mem-prot-doc-test branch from f3d4109 to 48ebb7a Compare April 20, 2026 03:05
@bengl bengl added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 20, 2026
Copy link
Copy Markdown
Contributor

@ShogunPanda ShogunPanda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ShogunPanda ShogunPanda removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 20, 2026
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@ShogunPanda
Copy link
Copy Markdown
Contributor

@bengl https://ci.nodejs.org/job/node-test-binary-windows-js-suites/40143/ - This is the only relevant failure.

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@addaleax addaleax added the ffi Issues and PRs related to experimental Foreign Function Interface support. label Apr 20, 2026
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@ShogunPanda ShogunPanda added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Apr 21, 2026
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Apr 21, 2026
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/62818
βœ”  Done loading data for nodejs/node/pull/62818
----------------------------------- PR info ------------------------------------
Title      doc,test: mem protection must be observed in ffi (#62818)
Author     Bryan English <bryan@bryanenglish.com> (@bengl)
Branch     bengl:bengl/ffi-mem-prot-doc-test -> nodejs:main
Labels     needs-ci, commit-queue-squash, ffi
Commits    3
 - doc,test: mem protection must be observed in ffi
 - fixup! doc,test: mem protection must be observed in ffi
 - fixup! fixup! doc,test: mem protection must be observed in ffi
Committers 1
 - Bryan English <bryan@bryanenglish.com>
PR-URL: https://github.com/nodejs/node/pull/62818
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/62818
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
--------------------------------------------------------------------------------
   β„Ή  This PR was created on Sun, 19 Apr 2026 04:39:14 GMT
   βœ”  Approvals: 1
   βœ”  - Paolo Insogna (@ShogunPanda) (TSC): https://github.com/nodejs/node/pull/62818#pullrequestreview-4146967369
   ✘  This PR needs to wait 114 more hours to land (or 0 minutes if there is one more approval)
   βœ”  Last GitHub CI successful
   β„Ή  Last Full PR CI on 2026-04-21T04:58:19Z: https://ci.nodejs.org/job/node-test-pull-request/72808/
- Querying data for job/node-test-pull-request/72808/
βœ”  Build data downloaded
   βœ”  Last Jenkins CI successful
--------------------------------------------------------------------------------
   βœ”  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/24718303601

@bengl bengl added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue-failed An error occurred while landing this pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. ffi Issues and PRs related to experimental Foreign Function Interface support. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants